package com.lyz;

import com.lyz.interceptors.AuthInterceptor;
import com.lyz.services.SessionService;
import com.lyz.services.impl.DefaultSessionService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties
public class AuthAutoConfigure {

    @Bean
    @ConditionalOnMissingBean
    public <T> SessionService<T> sessionService() {
        return new DefaultSessionService<>();
    }

    @Bean
    public <T> AuthInterceptor<T> authInterceptor(SessionService<T> sessionService) {
        return new AuthInterceptor<>(sessionService);
    }

}
